package com.fqcar.fqdf.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeUtils {

    public static String getMinute4TripList(int minute) {
        String str = "";

        if (minute >= 60) {
            int hour = minute / 60;
            str = hour + "小时";

            int tmp = minute - hour * 60;
            if (tmp > 0)
                str += tmp + "分钟";
        } else {
            str = minute + "分钟";
        }

        return str;
    }

    public static String getTime4CurrentOrder(int second) {
        String str = "";

        if (second < 0) {
            str = "即将开始用车";
        } else {
            int minute = second / 60;
            if (minute == 0) {
                str = "1分钟之内开始计费";
            } else {
                str = minute + "分钟" + "后开始计费";
            }
        }
/*		if(second < 0)
            str = "即将开始用车";
		else if(second < 60)
			str = second + "秒后开始计费";
		else {
			int minute = second / 60;
			second = second - minute * 60;
			str = minute + "分" + "后开始计费";
		}*/

        return str;
    }

    public static String getTime4TripList(int time) {
        SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日 HH时mm分");
        return sdf.format(new Date(time * 1000L));
    }

    public static String getTime4InvoiceList(int time) {
        SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日 HH时mm分");
        return sdf.format(new Date(time * 1000L));
    }

    public static String getTime4CouponsList(int time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        return sdf.format(new Date(time * 1000L));
    }

    public static String getTime4SettlementOrderDetail(int time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
        return sdf.format(new Date(time * 1000L));
    }

    public static String getTime4BalanceList(int time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
        return sdf.format(new Date(time * 1000L));
    }

    public static String getTime4ScoreList(int time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
        return sdf.format(new Date(time * 1000L));
    }

    public static String getTime4OrderDetail(int time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(new Date(time * 1000L));
    }

    public static String getTime4OrderIllegal(int time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(new Date(time * 1000L));
    }

    /**
     * 调用此方法输入所要转换的时间戳输入例如（1402733340）输出（"MM-dd HH:mm"）
     *
     * @param time
     * @return
     */
    public static String getTimeday(String time) {
        long now = TimeUtils.getCurrentTime() / 24 / 3600;
        long lcc = Long.valueOf(time);
        long input = lcc / 24 / 3600;
        if (now == input) {
            SimpleDateFormat sdr = new SimpleDateFormat("HH:mm");
            int i = Integer.parseInt(time);
            String times = sdr.format(new Date(i * 1000L));
            return "今天 " + times;
        } else if (now - input == 1) {
            SimpleDateFormat sdr = new SimpleDateFormat("HH:mm");
            int i = Integer.parseInt(time);
            String times = sdr.format(new Date(i * 1000L));
            return "昨天 " + times;
        } else if (now - input == 2) {
            SimpleDateFormat sdr = new SimpleDateFormat("HH:mm");
            int i = Integer.parseInt(time);
            String times = sdr.format(new Date(i * 1000L));
            return "前天 " + times;
        } else {
            SimpleDateFormat sdr = new SimpleDateFormat("MM月dd日 HH:mm");
            int i = Integer.parseInt(time);
            String times = sdr.format(new Date(i * 1000L));
            return times;
        }
    }

    /***
     * 获得当前秒级时间
     *
     * @return 距离0时间, 的秒级时间间隔
     */
    public static long getCurrentTime() {
        return System.currentTimeMillis() / 1000;
    }


}
